package com.zxp.quartz.demo.task;

import org.quartz.DisallowConcurrentExecution;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.quartz.PersistJobDataAfterExecution;
import org.springframework.scheduling.quartz.QuartzJobBean;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 *  @DisallowConcurrentExecution 不允许并发执行， 任务执行完才会进行下一个任务
 *  @PersistJobDataAfterExecution 执行后持久化jobDetail里面的dataMap
 */
@DisallowConcurrentExecution
@PersistJobDataAfterExecution
public class TestTask2  extends QuartzJobBean {

    @Override
    public void executeInternal(JobExecutionContext context) throws JobExecutionException {
        Date date = new Date();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        System.out.println(Thread.currentThread().getName() + " " +sdf.format(date) + " Task2：精神导师----");
    }
}
